package com.example.redis.demos.web.Redis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.HashMap;
import java.util.Map;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2024-07-13
 * Time:11:48
 * Text：
 */
public class Redis_Zset {
    public static void main(String[] args) {
        JedisPool jedisPool = new JedisPool("120.46.91.1",6379);
        try(Jedis jedis = jedisPool.getResource()){
            jedis.auth("2287448684t");
            Test2(jedis);
        }
    }
    public static void Test1(Jedis jedis){
        System.out.println("---ZADD--ZRANGE------");
        jedis.flushAll();

        jedis.zadd("key",10,"张三");
        Map<String,Double> t1 = new HashMap<>();
        t1.put("k1",12.9);
        t1.put("k2",23.9);

        jedis.zadd("key1",t1);

        System.out.println(jedis.zrange("key1",0,-1));
        System.out.println(jedis.zrangeWithScores("key1",0,-1));
    }
    public static  void Test2(Jedis jedis){
        System.out.println("----ZCARD--- zrem----zscore--");
        System.out.println(jedis.zcard("key"));
        System.out.println(jedis.zrem("key1","k1"));


        jedis.flushAll();
    }
}
